package com.itheima.test02;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

@SuppressWarnings("all")
public class Demo {
    static Scanner sc = new Scanner(System.in);
    static ArrayList<Manager> list = new ArrayList<>();
    static ArrayList<Subway> list2 = new ArrayList<>();
    public static void main(String[] args) {
        System.out.println("北京地铁管理系统:");
        Manager m1 = new Manager(10001, "小王", "男", "13112345678");
        Manager m2 = new Manager(10002, "老于", "男", "13212345678");
        Manager m3 = new Manager(10003, "小于", "男", "13312345678");
        Collections.addAll(Demo.list, m1, m2, m3);
        Subway s1 = new Subway("s3002", "南锣鼓巷", "6号线");
        Subway s2 = new Subway("s5016", "王府井", "1号线");
        Subway s3 = new Subway("s2026", "西直门", "4号线");
        Collections.addAll(list2, s1, s2, s3);
        addMassage(list);
        //System.out.println(list);
        //System.out.println(list2);
        while (true) {
            System.out.println("1 查看地铁，2,添加地铁,3退出");
            String str = sc.next();
            switch (str) {
                case "1":
                    look(list2);
                    break;
                case "2":
                    add(list2);
                    break;
                case "3":
                    return;
                default:
                    System.out.println("您的输入有误，请重新输入");
            }
        }
    }

    private static void addMassage(ArrayList<Manager> List) {
        while (true) {
            System.out.println("请输入管理员工号");
            int id = sc.nextInt();
            System.out.println("请输入管理员姓名");
            String name = sc.next();
            for (Manager manager : list) {
                if (id==(manager.getId()) && name.equals(manager.getName())) {
                    System.out.println("登录成功");
                    return;
                }
            }
            System.out.println("登录失败，您输入的工号或者姓名有误");
        }
    }

    public static void look(ArrayList<Subway> list2) {
        if (list2 == null) {
            System.out.println("请添加地铁信息");
            return;
        } else {
            for (int i = 0; i < list2.size(); i++) {
                System.out.println(list2.get(i));
            }
        }
    }

    public static void add(ArrayList<Subway> list2) {
        System.out.println("请输入地铁编号");
        String subwayNumber = sc.next();
        System.out.println("请输入地铁名称");
        String subwayName = sc.next();
        System.out.println("请输入所属路线");
        String subwayPath = sc.next();
        Subway sb = new Subway(subwayNumber, subwayName, subwayPath);
        list2.add(sb);
        System.out.println("添加成功!");
    }
}


